package cn.strive.eams.roomHave.controller;

import cn.strive.eams.base.response.JsonResult;
import cn.strive.eams.roomHave.pojo.dto.RoomHaveQuery;
import cn.strive.eams.roomHave.pojo.dto.RoomHaveSaveParam;
import cn.strive.eams.roomHave.pojo.vo.RoomHaveVO;
import cn.strive.eams.roomHave.service.RoomHaveService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/v1/roomHave")
@Api(tags = "房间资产管理")
@Slf4j
public class RoomHaveController {
    @Autowired
    RoomHaveService roomHaveService;

    @GetMapping("/select")
    @ApiOperation(value = "查询房间里的资产")
    public JsonResult selectAll(RoomHaveQuery roomHaveQuery){
        log.info("查询房间里的资产:roomHaveQuery={}", roomHaveQuery);
        List<RoomHaveVO> list = roomHaveService.selectAll(roomHaveQuery);
        return JsonResult.ok(list);
    }

    @PostMapping("/save")
    @ApiOperation(value = "添加房间里的资产")
    public JsonResult save(RoomHaveSaveParam roomHaveSaveParam){
        log.debug("添加资产到房间:roomHaveSaveParam={}",roomHaveSaveParam);
        roomHaveService.save(roomHaveSaveParam);
        return JsonResult.ok();
    }




    @DeleteMapping("/delete/{id}")
    @ApiOperation(value = "删除房间里的资产")
    public JsonResult deleteById(@PathVariable Long id){
        log.debug("删除房间里的资产:id={}",id);
        roomHaveService.deleteById(id);
        return JsonResult.ok();
    }


}
